﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KPI.Utility;
using KPI.OrganizationDomain.Model.Entity;

namespace KPI.OrganizationDomain.Infrastructure.DbObject
{
    public class DepartmentTab : EntityBase
    {
        public int DepartmentID { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
        public int ParentDepartmentID { get; set; }
        

        /// <summary>
        /// Initializes a new instance of the <see cref="DepartmentTab"/> class.
        /// </summary>
        public DepartmentTab() { }

        /// <summary>
        /// Initializes a new instance of the <see cref="DepartmentTab"/> class.
        /// </summary>
        /// <param name="department">The department.</param>
        public DepartmentTab(Department department)
        {
            this.CreatedDate = department.CreatedDate;
            this.DepartmentID = department.DepartmentID;
            this.Description = department.Description;
            if (department.ParentDepartment != null)
                this.ParentDepartmentID = department.DepartmentID;
            this.IsDeleted = department.IsDeleted;
            this.LastModifiedDate = department.LastModifiedDate;
            this.Name = department.Name;
            this.Version = department.Version;
        }

        /// <summary>
        /// Fills the department.
        /// </summary>
        /// <param name="copy">The department.</param>
        /// <param name="source">The department DBO.</param>
        /// <returns></returns>
        public static Department FillDepartment(DepartmentTab source, Department copy)
        {
            copy.DepartmentID = source.DepartmentID;
            return source.Copy<Department>(copy);
        }
    }
}